<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8">
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <link rel="Bookmark" href="/favicon.ico" >
    <link rel="Shortcut Icon" href="/favicon.ico" />
    <!--[if lt IE 9]>
    <script type="text/javascript" src="__PUBLIC__/admin/lib/html5shiv.js"></script>
    <script type="text/javascript" src="__PUBLIC__/admin/lib/respond.min.js"></script>
    <![endif]-->
    <link rel="stylesheet" type="text/css" href="__PUBLIC__/admin/static/h-ui/css/H-ui.min.css" />
    <link rel="stylesheet" type="text/css" href="__PUBLIC__/admin/static/h-ui.admin/css/H-ui.admin.css" />
    <link rel="stylesheet" type="text/css" href="__PUBLIC__/admin/lib/Hui-iconfont/1.0.8/iconfont.css" />
    <link rel="stylesheet" type="text/css" href="__PUBLIC__/admin/static/h-ui.admin/skin/default/skin.css" id="skin" />
    <link rel="stylesheet" type="text/css" href="__PUBLIC__/admin/static/h-ui.admin/css/style.css" />
    <!--[if IE 6]>
    <script type="text/javascript" src="__PUBLIC__/admin/lib/DD_belatedPNG_0.0.8a-min.js" ></script>
    <script>DD_belatedPNG.fix('*');</script>
    <![endif]-->
    <script type="text/javascript" src="__PUBLIC__/admin/js/jquery.js"></script>
    <script type="text/javascript" src="__PUBLIC__/admin/js/action.js"></script>
    <script type="text/javascript" src="__PUBLIC__/plugins/xheditor/xheditor-1.2.1.min.js"></script>
    <script type="text/javascript" src="__PUBLIC__/plugins/xheditor/xheditor_lang/zh-cn.js"></script>
    <script type="text/javascript" src="__PUBLIC__/admin/js/jCalendar.js"></script>

    <script type="text/javascript" charset="utf-8" src="__PUBLIC__/admin/kindeditor/kindeditor.js"></script>
    <script charset="utf-8" src="__PUBLIC__/admin/kindeditor/lang/zh_CN.js"></script>
    <script language="javascript">
        var editor;
        KindEditor.ready(function(K) {
            editor = K.create('#intro');
            // editor = K.create('#editor_id');多个
        });
    </script>
    <title>{$title}</title>
</head>
<body>
<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> {$modules} <span class="c-gray en">&gt;</span> {$title}
</nav>
<div class="page-container">
    <form class="form form-horizontal" action="{:U('save')}" method="post" onsubmit="return ac_from();" enctype="multipart/form-data">
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>封面图：</label>
            <div class="formControls col-xs-8">
                <input id="fileInput"  type="file" name="file" id="file" value="{$news.cover}" style="display: none;">
                <div id="chooseImage" style="">
                    <?php if ($news['cover']) { ?>
                    <img src="__DATA__/<?php echo $news['cover']; ?>" width="250" height="150" /><br /><br />
                    <?php }else{ ?>
                    点击上传图片
                    <?php } ?>
                </div>
                <span style="display: block; margin-top: 10px; color: #666">宽750 x 高450， 大小限制在1M以内</span>
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>标题：</label>
            <div class="formControls col-xs-8">
                <input type="text" class="input-text" placeholder="标题" name="title" id="title" value="{$news.title}">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3">时间：</label>
            <div class="formControls col-xs-8">
                <input type="text" class="input-text" placeholder="时间" name="ac_time" id="ac_time" value="{$news.ac_time}">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3">地址：</label>
            <div class="formControls col-xs-8">
                <input type="text" class="input-text" placeholder="地址" name="address" id="address" value="{$news.address}">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>内容：</label>
            <div class="">
                <textarea id="intro" name="content" style="width:700px;height:500px;"/>{$news.content}</textarea>
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3">排序：</label>
            <div class="formControls col-xs-8">
                <input type="text" class="input-text" placeholder="排序，选填，数字越小排名越前" name="sort" value="{$news.sort}">
            </div>
        </div>
        <div class="row cl">
            <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
                <input class="btn btn-primary radius" type="submit" name="submit" value="&nbsp;&nbsp;提交&nbsp;&nbsp;">
                <input type="hidden" name="id" value="{$news.id}">
            </div>
        </div>
    </form>
</div>
<script type="text/javascript" src="__PUBLIC__/admin/js/product.js"></script>
<script>
    $(function () {

        //初始化编辑器
        $('#content').xheditor({
            skin:'nostyle' ,
            upImgUrl:'{:U("Upload/xheditor")}'
        });

        // 图片选择
        $("#chooseImage").click(function () {
            $("#fileInput").click();
        })

        // 图片显示
        $("#fileInput").change(function () {
            var obj = $("#fileInput")[0].files[0];
            var fr = new FileReader();
            fr.onload=function () {
                $("#chooseImage").html("<img width='250' height='150' src='"+this.result+"'>")
            };
            fr.readAsDataURL(obj);
        })
    })

    function ac_from(){
        var fileInput = $("#fileInput").val();
        var title = $("#title").val();
        var id = $("#id").val();

        if(fileInput == '' && id == 'undefined'){
            alert('请上传封面图片');
            return false;
        }

        if(title == ''){
            alert('请填写标题');
            return false;
        }

        $(".btn-primary").attr('disabled', 'disabled').val('提交中');
    }
</script>

</body>
</html>
